<?php
defined('IN_ADMIN');
//defined('IN_SITE') or exit('Access Denied');

//require '../includes/common.inc.php';
require 'form.class.php';



require_once MOD_ROOT.'content/content.class.php';
$c = new content();
require_once MOD_ROOT.'attachment/attachment.class.php';
$attachment = new attachment($module, $catid);
require_once 'regular.class.php';
$regular = new regular();


switch($action){
	case 'test':
		
	break;
	
	case 'delete':
		if($contentid){
			$c->delete($contentid);
			showmessage('操作成功！', "?");
		}
	break;
	
	default:
		if($dosubmit)
		{
			$info['status'] = 99;
			
			// 内容伪原创，所有伪原创规则在类里面操作，需要修改的话直接修改类即可 aming
			$info['content'] = $regular->original($info['content']);
			$c->edit($contentid, $info);
			showmessage('修改成功！', "?profile=$profile");
		}
		else
		{
			// 如果没有传入id则默认选择最后发布的待审核文章作为修改
			$data = $db->get_one("select `contentid` from ".DB_PRE."content where status in(3,5,2) order by contentid desc");
			if(!$data){
				showmessage('没有等待伪原创的文章，请先到后台添加或采集！');
			}
			
			$contentid = $contentid ? $contentid : $data['contentid'];
			
			// 以下摘自后台内容修改代码片段
			if(is_numeric($contentid) && $contentid>0)
			{
				$data = $c->get($contentid);
				$catid = $data['catid'];
				$modelid = $CATEGORY[$catid]['modelid'];
			}
			//$data['content'] = str_replace('渴望','<b title="的替换为地">渴切</b>',$data['content']);
			
			require CACHE_MODEL_PATH.'content_form.class.php';
			$content_form = new content_form($modelid);
			$forminfos = $content_form->get($data);

			/*unset($forminfos['base']['content']);
			dump($forminfos); exit();*/
			
			include ('regular.tpl.php');
		}
		break;
	break;
}
?>
